import request from "@/utils/request";

const USER_BASE_URL = "/api/v1/user";

const ConsumerUserAPI = {
  /**
   * 获取商户用户列表
   *
   * @param queryParams 查询参数（可选）
   * @returns 用户列表
   */
  getList(queryParams?: ConsumerUserQuery) {
    return request<any, ConsumerUserPageVO[]>({
      url: `${USER_BASE_URL}/consumerUser/page`,
      method: "post",
      data: queryParams,
    });
  },
  /**
   * 更新商户用户状态
   *
   * @param id 用户ID
   * @param status 状态
   * @returns 更新结果
   */
  updateStatus(userId: number, status: number) {
    return request<any, any>({
      url: `${USER_BASE_URL}/consumerUser/updateStatus`,
      method: "get",
      params: { userId, status },
    });
  },
  /**
   * 绑定B端合伙人
   * @param data
   */
  updateBPartner(data: MerchantBPartnerForm) {
    return request<any, any>({
      url: `${USER_BASE_URL}/consumerUser/updateBPartner`,
      method: "post",
      data,
    });
  },
};

export default ConsumerUserAPI;

/** 用户查询参数 */
export interface ConsumerUserQuery {
  /** 页码 */
  pageNum?: number;
  /** 每页条数 */
  pageSize?: number;
}
export interface ConsumerUserPageVO {
  list: ConsumerUserVO[];
  total: number;
}
export interface ConsumerUserVO {
  id: number;
  username: string;
  nickname: string;
  gender: number;
  password: string;
  avatar: string;
  mobile: string;
  status: number;
  email: string;
  createTime: string;
  createBy: string;
  updateTime: string;
  updateBy: string;
  isDeleted: number;
  openid: string;
  remark: string;
}

/**
 * 商户 B 端合伙人表单对象
 */
export interface MerchantBPartnerForm {
  /** 用户类型 */
  userType: string;

  /** 公司 ID */
  companyId?: number;

  /** 设计师 ID */
  merchantUserId?: number;

  /** 高级合伙人 ID */
  partnerId?: number;
}
